"""websocket路由"""

from fastapi import WebSocket, FastAPI
from ws_handle import GatewayApp, GmApp
from main import app


async def handler_gateway(websocket: WebSocket):
    await GatewayApp(websocket).handle()


async def handler_gm(websocket: WebSocket):
    await GmApp(websocket).handle()


def init_route():
    path2Handle = {
        "/gateway": handler_gateway,
        "/gm": handler_gm,
    }
    for path, handle in path2Handle.items():
        app.add_websocket_route(path, handle)
